/**
 *
 */
package com.wedroid.r2d2.support.response.login;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author lute
 *
 */
public class UUIDResponse extends AbstractLoginResponse {

    private static final String REGEX = "window.QRLogin.code = (\\d+); window.QRLogin.uuid = \"(\\S+?)\"";

    private Pattern pattern;

    private String uuid;

    /**
     *
     */
    public UUIDResponse() {
        this.pattern = Pattern.compile(REGEX);
    }

    /* (non-Javadoc)
     * @see com.wedroid.r2d2.support.response.DroidResponse#parse(java.lang.String)
     */
    public void parse(String response) {
        Matcher matcher = pattern.matcher(response);
        if (matcher.find()) {
            int code = Integer.valueOf(matcher.group(1));
            this.status = LoginStatus.codeOf(code);
            this.uuid = matcher.group(2);
        }
    }

    /**
     * @return the uuid
     */
    public String getUuid() {
        return uuid;
    }

}
